<?php
namespace Suggest\Controller;
use Admin\Controller\AdminbaseController;
use Admin\Controller\PublicController;
class PingjiaController extends AdminbaseController {
	
	protected $m;
	protected $mm;
	
	function _initialize() {
		parent::_initialize();
		$this->m = D('YgclPingjia');
		$this->mm = D('YgclPingjiaTeacher');
	}
	
	public function index(){
		if(!$_GET['status']){
			$_GET['status'] = 0;
		}
		$this->display();
	}
	
	public function del(){
		$id = array_unique((array)I('ids',0));
		if ( empty($id) ) {
			$this->error('请选择要操作的数据!');
		}
		$map = array('id' => array('in', $id));
		$info = $this->m->where($map)->find();
		if($this->m->where($map)->delete()){
			$this->success('删除成功',U('index'));
		} else {
			$this->error('删除失败！');
		}
	}
	
	public function getinfo($cid,$ctid){
		$cinfo = D('YgclClass')->where(array('id'=>$cid))->relation(true)->find();
// 		dump($cinfo);
		$cttitle = D('YgclClassType')->where(array('id'=>$ctid))->getField('title');
		return $cinfo['title'].'('.$cttitle.')<br/>'.$cinfo['district'];
	}
	
	public function teacher(){
		if(!$_GET['status']){
			$_GET['status'] = 0;
		}
		$this->display();
	}
	
	public function teacherdel(){
		$id = array_unique((array)I('ids',0));
		if ( empty($id) ) {
			$this->error('请选择要操作的数据!');
		}
		$map = array('id' => array('in', $id));
		if($this->mm->where($map)->delete()){
			$this->success('删除成功',U('index'));
		} else {
			$this->error('删除失败！');
		}
	}
	
	public function getteacherinfo($tid){
		return D('Users')->where(array('uid'=>$tid))->getField('realname');
	}
}